Ext.define('console.internalEvalRecordWindow', {
    extend: 'Ext.ux.desktop.Module',

    requires: [
        'console.store.deptStore',
        'console.store.internalEvalRecordStore',
        'Ext.util.Format',
        'Ext.grid.Panel',
        'Ext.grid.RowNumberer'
    ],

    id: 'internalEvalRecordWindow',
    init: function () {
        this.launcher = {
            text: '评价管理',
            iconCls: 'icon-grid'
        };
    },

    createWindow: function () {
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('internalEvalRecordWindow');
        if (!win) {
            win = desktop.createWindow({
                id: 'internalEvalRecordWindow',
                title: '内部评价管理',
                width: 780,
                height: 500,
                iconCls: 'icon-grid',
                items: [
                    {
                        xtype: 'grid',
                        itemId: 'master',
                        store: Ext.createWidget('internalEvalRecordStore'),
                        columns: [{xtype: 'rownumberer'},
                            {
                                text: "月份",
                                sortable: true,
                                dataIndex: 'month'
                            }, {
                                text: "科室/部门类别",
                                sortable: true,
                                dataIndex: 'groupName'
                            },
                            {
                                text: "科室/部门",
                                sortable: true,
                                dataIndex: 'deptName'
                            },
                            {
                                text: "已填数量",
                                sortable: true,
                                dataIndex: 'fillCount'
                            },
                            {
                                text: "该填数量",
                                sortable: true,
                                dataIndex: 'shouldFillCount'
                            }
                        ],
                        tbar: [{
                            text: '生成下月的填报表',
                            tooltip: '添加评价分组',
                            iconCls: 'add',
                            handler: this.generate
                        }, '-', {
                            text: '删除评价分组',
                            tooltip: '删除评价分组',
                            iconCls: 'remove',
                            handler: this.showDetails
                        }]
                    }
                ]
            });
        }
        return win;
    },


    generate: function () {
        Ext.Ajax.request({
            url: 'internalEvalRecord/generatorEvalList',
            success: function (response) {
                var res = Ext.decode(response.responseText);
                if (res.success) {
                    Ext.Msg.alert('提示', '操作成功');
                } else {
                    Ext.Msg.alert('操作失败', res.failure);
                }
            },
            failure: function (action) {
                Ext.Msg.alert('', '操作信息失败');
            }
        });
    },


    showDetails: function () {

    }
});

